/*
 * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0.
 *
 * @Date: 2021-04-07 09:53:07
 * @LastEditTime: 2021-08-16 15:18:59
 * @Description:  This files is for type definition
 *
 * @Modify History:
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 */

#include "ft_types.h"
#include "ft_assert.h"
#include "stdio.h"
/************* 全局变量 用于判断驱动是否出现断言 *****************/
u32 ft_assert_status;

/************** 断言是否需要无限等待，1 等待，0不等待  ******************/
s32 ft_assert_wait = 1;

/* 当断言发生时，将会调用此函数 */

_WEAK void _BspAssertCallback(const char *File, s32 Line)
{
    printf("Assert Error is %s : %ld \r\n", File, Line);
}

static FtAssertCallback ft_assert_cb = (FtAssertCallback)_BspAssertCallback;

/************************** Function Prototypes ******************************/
void FtAssert(char *file, s32 Line)
{
    if (ft_assert_cb != NULL)
    {
        ft_assert_cb(file, Line);
    }

    while (ft_assert_wait != 0)
    {
    }
}

void FtAssertSetCb(FtAssertCallback routine)
{
    ft_assert_cb = routine;
}
